<template>
    <el-form :model="cTowerForm" status-icon :rules="rules" ref="cTowerForm"
             label-width="150px"
             style="margin-top: 10px;color: #1f2d3d">
        <el-form-item class="form-label" label="电视塔编号" prop="tid">
            <el-col :span="19">
                <el-input v-model="cTowerForm.tid" placeholder="电视塔编号"
                          maxlength="11" autocomplete="tid"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="电视塔名称" prop="objectName">
            <el-col :span="19">
                <el-input v-model="cTowerForm.objectName" placeholder="电视塔名称"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="地理位置" prop="location">
            <el-col :span="19">
                <el-input v-model="cTowerForm.location" placeholder="地理位置"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="经度" prop="longitude">
            <el-col :span="19">
                <el-input v-model="cTowerForm.longitude" placeholder="经度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="纬度" prop="latitude">
            <el-col :span="19">
                <el-input v-model="cTowerForm.latitude" placeholder="纬度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="结构类型" prop="structType">
            <el-col :span="19">
                <el-input v-model="cTowerForm.structType" placeholder="结构类型"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="建筑面积" prop="structArea">
            <el-col :span="19">
                <el-input v-model="cTowerForm.structArea" placeholder="建筑面积"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="建筑年代" prop="year">
            <el-col :span="19">
                <el-input v-model="cTowerForm.year" placeholder="建筑年代"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="总高度" prop="strutHeight">
            <el-col :span="19">
                <el-input v-model="cTowerForm.strutHeight" placeholder="总高度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="塔楼处标高" prop="towerElevation">
            <el-col :span="19">
                <el-input v-model="cTowerForm.towerElevation" placeholder="塔楼处标高"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="建筑物场址" prop="buldingSite">
            <el-col :span="19">
                <el-input v-model="cTowerForm.buldingSite" placeholder="建筑物场址(有利/不利)"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="设防标准" prop="intensity">
            <el-col :span="19">
                <el-input v-model="cTowerForm.intensity" placeholder="设防标准"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="场地类型" prop="fieldType">
            <el-col :span="19">
                <el-input v-model="cTowerForm.fieldType" placeholder="场地类型"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="现状评价" prop="status">
            <el-col :span="19">
                <el-input v-model="cTowerForm.status" placeholder="现状评价"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="重建单位面积造价" prop="reconstructionCost">
            <el-col :span="19">
                <el-input v-model="cTowerForm.reconstructionCost" placeholder="重建单位面积造价(每平米重建造价)"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="天线处底部标高" prop="antennaElevation">
            <el-col :span="19">
                <el-input v-model="cTowerForm.antennaElevation" placeholder="天线处底部标高"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="基本周期" prop="period">
            <el-col :span="19">
                <el-input v-model="cTowerForm.period" placeholder="基本周期(单位：秒)"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="塔柱结构类型" prop="colmnType">
            <el-col :span="19">
                <el-input v-model="cTowerForm.colmnType" placeholder="塔柱结构类型"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="塔柱底座结构类型" prop="baseType">
            <el-col :span="19">
                <el-input v-model="cTowerForm.baseType" placeholder="塔柱底座结构类型"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="塔座层数" prop="baseStoryNum">
            <el-col :span="19">
                <el-input v-model="cTowerForm.baseStoryNum" placeholder="塔座层数"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="塔座高度" prop="baseHeight">
            <el-col :span="19">
                <el-input v-model="cTowerForm.baseHeight" placeholder="塔座高度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="关联子任务" prop="sid" style="display: none">
            <el-input v-model="cTowerForm.sid"
                      maxlength="20" autocomplete="off"/>
        </el-form-item>
    </el-form>
</template>

<script>
    import qs from 'qs';

    export default {
        name: "NewCorrespondTower",
        data() {
            return {
                cTowerForm: {
                    id: '',
                    tid: '',
                    objectName: '',
                    location: '',
                    longitude: '',
                    latitude: '',
                    structType: '',
                    structArea: '',
                    year: '',
                    strutHeight: '',
                    towerElevation: '',
                    buldingSite: '',
                    intensity: '',
                    fieldType: '',
                    status: '',
                    reconstructionCost: '',
                    antennaElevation: '',
                    period: '',
                    colmnType: '',
                    baseType: '',
                    baseStoryNum: '',
                    baseHeight: '',
                    sid: ''
                },
                rules: {
                    tid: [],
                    objectName: [],
                    location: [],
                    lon: [],
                    lat: [],
                    structType: [],
                    structArea: [],
                    year: [],
                    strutHeight: [],
                    towerElevation: [],
                    buldingSite: [],
                    intensity: [],
                    fieldType: [],
                    status: [],
                    reconstructionost: [],
                    antennaElevation: [],
                    period: [],
                    colmnType: [],
                    baseType: [],
                    baseStoryNum: [],
                    baseHeight: []
                }
            }
        },
        mounted() {
            if (this.id !== -1) {
                axios.post("/bjdzms/correspondTvTower/findById",
                    qs.stringify({
                        'id': this.id
                    })).then(res => {
                    this.cTowerForm = res.data.datas;
                });
            }
        },
        props: {
            sid: {
                type: Number,
                default: -1
            },
            id: {
                type: Number,
                default: -1
            }
        },
        methods: {
            to(path) {
                this.$router.push({name: path});
            },
            submitForm() {
                if (this.id !== -1) {
                    this.cTowerForm.id = this.id;
                    axios.post("/bjdzms/correspondTvTower/upd",
                        qs.stringify(this.cTowerForm)
                    ).then(res => {
                        this.$emit('updateData');
                    });
                } else {
                    this.cTowerForm.sid = this.sid;
                    axios.post("/bjdzms/correspondTvTower/add",
                        qs.stringify(this.cTowerForm)
                    ).then(res => {
                        this.$emit('updateData');
                    });
                }
            }
        }
    }
</script>

<style>
    .el-upload-dragger {
        height: 40px !important;
    }
</style>

<style scoped>
    .el-header {
        background: #EBEBEB;
        color: #e5e9ef;
        font-size: 2em;
        line-height: 80px;
        border: 5px solid #EBEBEB;
    }

    .el-main {
        background: #fff;
    }

    .el-container {
        height: 100%;
    }

    .el-form-item {
        width: 610px;
    }
</style>
